<?php

namespace App\Models\Project;

use App\Models\SignCompany;
use Illuminate\Database\Eloquent\SoftDeletes;

class Contract extends Base
{
    use SoftDeletes;

    protected $table = 'pm_contracts';

    protected $fillable = [
        'project_name',
        'contract_number',
        'project_type_id',
        'scale_data',
        'sign_company_id',
        'other_company_name',
        'other_company_contact',
        'other_company_mobile',
        'signed_at',
        'contract_amount',
        'pay_times',
        'required_finish_at',
        'owner_unit',
        'owner_contact',
        'owner_mobile',
        'owner_address',
        'province_id',
        'city_id',
        'area_id',
        'detail_address',
        'cooperation_mode',
        'source',
        'source_contact_id',
        'source_company',
        'source_mobile',
        'professional_director_uid',
        'contract_director_uid',
        'inner_docking_uid',
        'external_costs_is_settlement',
        'progress_id',
        'approval_result',
        'operator_uid',
    ];

    protected $dates=[
        'signed_at',
        'required_finish_at',
    ];
    public function signCompany()
    {
        return $this->hasOne(SignCompany::class,'id','sign_company_id');
    }

    public function pendingBills()
    {
        return $this->hasMany(PendingBill::class);
    }

    public function paymentAgreements()
    {
        return $this->hasMany(PaymentAgreement::class);
    }

    public function logs()
    {
        return $this->hasMany(ContractLog::class);
    }

    public function attachments()
    {
        return $this->hasMany(ContractAttachment::class);
    }
}
